package com.adou.p2p.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.adou.p2p.interceptor.LoginInterceptor;

@Configuration
public class WebConfig implements WebMvcConfigurer {
//	@SuppressWarnings({ "rawtypes", "unchecked" })
//    @Bean
//    public FilterRegistrationBean filterRegist() {
//        FilterRegistrationBean frBean = new FilterRegistrationBean();
//        frBean.setFilter(new LoginFilter());
//        frBean.addUrlPatterns("/views/*");
//        return frBean;
//    }
	
	@Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册TestInterceptor拦截器
        InterceptorRegistration registration = registry.addInterceptor(new LoginInterceptor());
        registration.addPathPatterns("/views/**","/views/home.jsp");                      //所有路径都被拦截
        registration.excludePathPatterns("/login.jsp",			//不拦截
						        		"/**/*.html",            
						                "/**/*.js",              //js静态资源
						                "/**/*.css",             //css静态资源
						                "/**/*.img"
        								);             
    }
	
	
}
